#ifndef GRUB_SW_H
#define GRUB_SW_H	1
#define PAGE_OFFSET		0xfff0000000000000UL
#define KTEXT_OFFSET		0xffffffff80000000UL
#define GRUB_PRINTK_START       (PAGE_OFFSET | 0x800000)
#define GRUB_PRINTK_SIZE	(0x20000)
#define BOOT_PARAM_START	0xfff000000090a100ULL

#define GRUB_ELF_SEARCH         1024
#define IPL_MIN                 0
#define IPL_MAX                 7
#define barrier()               __asm__ __volatile__("": : :"memory")
#define local_irq_disable()     do { swpipl(IPL_MAX); barrier(); } while(0)
#define local_irq_enable()      do { barrier(); swpipl(IPL_MIN); } while(0)

static inline
grub_uint64_t
grub_virt_to_phys(grub_uint64_t x)
{
  if (x >= KTEXT_OFFSET)
    x -= KTEXT_OFFSET;
  else if (x >= PAGE_OFFSET)
    x -= PAGE_OFFSET;

  return x;
}

struct boot_param
{
  grub_uint64_t initrd_start;                   /* logical address of initrd */
  grub_uint64_t initrd_size;                    /* size of initrd */
  grub_uint64_t dtb_start;                      /* logical address of dtb */
  grub_uint64_t efi_systab;                     /* logical address of EFI system table */
  grub_uint64_t efi_memmap;                     /* logical address of EFI memory map */
  grub_uint64_t efi_memmap_size;                /* size of EFI memory map */
  grub_uint64_t efi_memdesc_size;               /* size of an EFI memory map descriptor */
  grub_uint64_t efi_memdesc_version;            /* memory descriptor version */
  grub_uint64_t command_line;                   /* logical address of cmdline */
};

struct linux_sw64_kernel_header
{
};

#define linux_arch_kernel_header linux_sw64_kernel_header

#endif
